class Myrunnable2 implements Runnable{
    @Override
    public void run(){
        while(true){
            System.out.println("hello Runnable");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}/*
    内部类访问问题：MyRunnable 是一个非静态内部类（实例内部类）在 main 静态方法中无法直接创建非静态内部类的实例
    */

public class Demo2 {
    public static void main(String[] args) throws InterruptedException {
        Runnable runnable=new Myrunnable2();
        //Runnable没有start方法，想要启动线程，就要搭配Thread
        Thread thread=new Thread(runnable);
        thread.start();
        while(true) {
            System.out.println("hello main");
            Thread.sleep(1000);
        }
    }
}
